package predicate

// Predicate 用在selector的where部分、having部分；不能设置别名
type Predicate struct {
	Left  Expression
	Op    op
	Right Expression
}

func (p Predicate) expr() {
}

func (p Predicate) Lt(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpLt,
		Left:  p,
		Right: predicate,
	}

}

func (p Predicate) Gt(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpGt,
		Left:  p,
		Right: predicate,
	}
}

func (p Predicate) Eq(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpEqual,
		Left:  p,
		Right: predicate,
	}
}

func (p Predicate) Le(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpLe,
		Left:  p,
		Right: predicate,
	}
}

func (p Predicate) Ge(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpGe,
		Left:  p,
		Right: predicate,
	}
}

func (p Predicate) And(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpAnd,
		Left:  p,
		Right: predicate,
	}
}
func (p Predicate) Or(predicate Predicate) Predicate {
	return Predicate{
		Op:    OpOr,
		Left:  p,
		Right: predicate,
	}
}

func Not(predicate Predicate) Predicate {
	return Predicate{
		Op:    opNot,
		Right: predicate,
	}
}

var _ Expression = Predicate{}
